package me.xplabs.magic 
{
	import me.xplabs.constant.MagicType;
	import me.xplabs.gemo.Point2D;
	import me.xplabs.model.skill.MSkillInfo;
	/**
	 * http://www.xplabs.me/
	 * @author xiaohan
	 * 远程技能特效
	 */
	public class LongDistanceMagic extends MSkillInfo 
	{
		private var _magicPath:BaseMagicPath;
		public function LongDistanceMagic() 
		{
			
		}
		public function initMagic(targetPoint2d:Point2D, sourcePoint2d:Point2D, speed:int, gravity:int = 1000, magicType:int = 2):void
		{
			if (magicType == MagicType.STRAIGHT)
			{
				_magicPath = new StraightMagic();
				StraightMagic(_magicPath).initialize(targetPoint2d, sourcePoint2d, speed);
			}else if (magicType == MagicType.PARABOLA)
			{
				_magicPath	= new ParabolaMagic();
				ParabolaMagic(_magicPath).initialize(targetPoint2d, sourcePoint2d, speed, gravity);
			}
			this.endX = targetPoint2d.x;
			this.endY = targetPoint2d.y;
			this.speed = speed;
			this.gravity = gravity;
			this.magicType = magicType;
			_magicPath.startPath();
			//angle = 180 * _magicPath.angle / Math.PI + 90;
			this.curPosX = _magicPath.curPoint2d.x;
			this.curPosY = _magicPath.curPoint2d.y;
		}
		
		override public function heartbeat(prev:uint):Boolean 
		{
			var boolean:Boolean = _magicPath.updateTrack(prev);
			this.curPosX = _magicPath.curPoint2d.x;
			this.curPosY = _magicPath.curPoint2d.y;
			angle = 180 * _magicPath.angle / Math.PI;
			return boolean; 
		}
		override public function dispose():void 
		{
			super.dispose();
		}
	}

}